package com.xds.gulimall.product.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

/**
 * @author : baixu
 * @date : 14:12 2021/12/16
 */
@Configuration
public class MyRedissonConfig {
    @Bean(destroyMethod = "shutdown")
    public  RedissonClient redisson() throws IOException {
        Config config=new Config();
        // 集群redis
//        config.useClusterServers().addNodeAddress("121.40.190.27:6379");
        //单节点redis
        // 报错  Redis url should start with redis:// or rediss://
        config.useSingleServer().setAddress("redis://121.40.190.27:6379");
        return Redisson.create(config);
    }
}
